package com.huobao.yunying.adapters;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.huobao.yunying.entity.ProgectList;
import com.huobao.yunying.utils.SkipUtils;
import com.huobao.yunying.views.NoScrollGridView;
import com.huobao.zhangying.R;

import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_Progect_Ex extends QuickAdapter<ProgectList> {


	/** 1:流通品 2:厂商直批 3:代理品 4:不予理会*/
	private int type;
	public Adapter_Progect_Ex(Context context, int type) {
		super(context, R.layout.item_progect_head);
		this.type = type;
	}

	@Override
	protected void convert(BaseAdapterHelper helper, final ProgectList arg1) {
		helper.setText(R.id.tv_title,"——"+arg1.getCate_name()+"——");
		NoScrollGridView gridview = helper.getView(R.id.gridview);
		Adapter_ProgectGridView adapter = new Adapter_ProgectGridView(context,arg1.getGoods_list());
		gridview.setOnItemClickListener(new ItemClick(arg1));
		gridview.setAdapter(adapter);
		helper.setOnClickListener(R.id.tv_text, new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				SkipUtils.skipToSearchList(context, arg1.getCateid()+"", null, type == 4 ? null : type+"", null, null, null);
			}
		});
	}


	private class ItemClick implements OnItemClickListener{

		private ProgectList progectList;
		public ItemClick(ProgectList progectList){
			this.progectList = progectList;
		}
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			SkipUtils.seeDetail(context, progectList.getGoods_list().get(position).getGoods_id(), progectList.getGoods_list().get(position).getDefault_image());
		}
		
	}

}
